<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script language="javascript" src="../script/common.js" type="text/javascript"></script>
 	<meta name="author" content="liunan">
	<title>EFT管理</title>
	<script type="text/javascript">	
	var org = Common.cOrg();	//当前单位	
	var qt = {};				//数据表格对象
	
	function load(){
		Eui.showNavigation();
		setPages(["listview","detview1","detview3","detview2"]);
		Common.initDict(searchForm.status,"pos_status","全 部");
		createTable();
	}
	function createTable(){
		var columns = [];
		columns[0]={type:"checkbox"} 
		columns[1]={render:uniqueId}
		columns[6]={title:"操作",width:"15%",render:handle,align:"center",order:false}
		qt = new QueryTable("pos_manage_query","searchForm","datalist",columns,{
			buttons:[
				{value:"批量添加EFT",actions:onNew1},
				{value:"添加EFT",actions:onNew},
				{value:"删除EFT",actions:onDelete}
			]
		});
	}
	function showData(){	
		qt.showTable();
	}
	function uniqueId(v,r){
		return "<a href=# onclick=\"onEdit("+r[0]+");return false;\">"+v+"</a>";		
	}
	function handle(v,r){
		return "<a href=# onclick=\"onUpdatePos("+r[0]+");return false;\">分配EFT</a> <a href=# onclick=\"onUpdatePage("+r[0]+");return false;\">修改EFT</a>";		
	}
	function onEdit(id){
		DWR.call("posMgntService.getPosInfo",id,function(v){
			var pos = v.pos;
			pos.status = Common.getText("pos_status",pos.status);
			pos.specName = v.specName;
			pos.location = v.location;
			Common.showDetail(posDetailForm,pos);
		});
		switchPage("detview3");
	}
	function onNew(){
		$('nospan').innerHTML="";
		posForm.reset();
		switchPage("detview1");
	}
	function onNew1(){
		batchPosForm.reset();
		switchPage("detview2");
	}
	function onDelete(){
		var ids = qt.getBoxValue();
		if(ids){
			Eui.onDel("posMgntService.deletePos",ids, "EFT", null, function() {
				qt.showTable();
			},qt.getBts());
		}else{
			showWarning("请选择要删除的EFT");
		}
	}
	function onUpdatePos(id){
		SystemMgnt.selOrgList(function(v){
			if (!v) return;
			if(showQuestion("请确认是否分配到"+v.name+"?")){
				DWR.call("posMgntService.updatePosLoction",id,{id:v.id},function(){
					showInformation("分配成功");
					showData();
				});
			}
		},{selOne:true,orgId:org.id,onlyChildren:true})
	}
	function onUpdatePage(id){
		DWR.call("posMgntService.getPosInfo",id,function(v){
			var pos = v.pos;
			pos.specName = v.specName;
			$('nospan').innerHTML="<label>EFT状态</label> <select name='status' onblur=\"checkV(this,'',true)\"></select><span class='des'>*</span>";
			Common.initDict(posForm.status,"pos_status","请选择");
			Common.setValues(posForm,pos);
		});
		switchPage("detview1");
	}
	function onSave(){
		if(!checkForm(posForm))return;
		if(!(showQuestion("您确认保存EFT吗?"))){
				return;
		}
		var posValue = Common.getValues(posForm);
		DWR.call("posMgntService.savePos",posValue,function(){
			showInformation("保存成功");
			switchPage("listview");
			showData();
			posForm.reset();
		},{blockScreen:true});
	}
	function onSaveBatch(){
		if(!checkForm(batchPosForm))return;
		var unBegin = batchPosForm.uniqueIdBegin.value;
		var unEnd = batchPosForm.uniqueIdEnd.value;
		if(Number(unEnd)<Number(unBegin)){
			showInformation("EFT起始编号不能大于EFT结束编号");
			return;
		}
		var number1 = (Number(unEnd)-Number(unBegin))+1;
		if (number1>10000) {showWarning("每次增加终端数量不能超过100000");return;}
		if(!(showQuestion("您确认保存" + number1 + "个EFT吗?"))){
			return;
		}
		var posValue = Common.getValues(batchPosForm);
		DWR.call("posMgntService.savePosBatch",unBegin,unEnd,posValue,function(){
			showInformation("保存成功");
			switchPage("listview");
			showData();
			posForm.reset();
		},{blockScreen:true});
	}
	
	function selPosSpecForSearch() {
		var v = openDialogFrame("/basic/sel_pos.html?",'请选择EFT规格',464,700)
		if(v){
			searchForm.specName.value = v.spec;
		}	
	}
	
	function selPos(){
		var v = openDialogFrame("/basic/sel_pos.html?",'请选择EFT规格',464,700)
		if(v){
			posForm.spec.value = v.id;
			posForm.specName.value = v.spec;
		}
	}
	function selPos1(){
		var v = openDialogFrame("/basic/sel_pos.html?",'请选择EFT规格',464,700)
		if(v){
			batchPosForm.spec.value = v.id;
			batchPosForm.specName.value = v.spec;
		}
	}

	//选择单位控件 回调方法
	function setOrg(){
		SystemMgnt.selOrgList(function(v){
			if (!v) return;
			searchForm.orgName.value = v.name;
		},{orgId:org.id,selOne:true})
	}
	function checkEndPos(){
		var unBegin = batchPosForm.uniqueIdBegin.value;
		var unEnd = batchPosForm.uniqueIdEnd.value;
		if(Number(unEnd)<Number(unBegin) && unEnd.length==12){
			errorStyle(batchPosForm.uniqueIdEnd,"EFT起始编号不能大于EFT结束编号");
			return;
		}
	}
	</script>
</head>
<body onload="load()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<!--查询静态页面部分-->
	<div id="listview">	
		<!--查询条件form-->
		<div class="searchForm">
			<form id="searchForm" name="searchForm">
				<table cellSpacing="0" cellPadding="4" width="100%" border="0">
					<tr>
						<td><label>所属机构</label> <input type="text" name="orgName" maxlength="32"><a class="orga" href="#" onclick="setOrg()">&nbsp;&nbsp;</a></td>
						<td><label>状&nbsp;&nbsp;&nbsp;&nbsp;态</label> <select name="status"></select></td>
						<td><label>EFT 规格</label> <input type="text" name="specName"> <a class="orga" title="选择EFT规格" href="javascript:void(0)" onclick="selPosSpecForSearch()">&nbsp;&nbsp;</a></td>
					</tr>
					<tr>
						<td><label>EFT 编号</label> <input type="text" name="uniqueId" onblur="checkV(this,'pos')" maxlength="32"></td>
						<td><label>EFT 名称</label> <input type="text" name="name" maxlength="20"></td>
						<td><button type="button" onclick="showData()">查 询</button></td>
					</tr>
				</table>
			</form>
		</div>
		<div id=datalist></div>
	</div>
	<div id="detview1" style="display:none;">
		<form id="posForm" name="posForm">
			<input type="hidden" name="id"/>
			<input type="hidden" name="spec"/>
			<div class=form>
			<div class="formTitle">EFT信息</div>
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="label6">
					<tr>
						<td><label>EFT编号</label> <input name="uniqueId" onblur="checkV(this,'pos',true)" maxlength="12"><span class="des">*</span></td>
						<td><label>EFT名称</label> <input name="name" onblur="checkV(this,'',true)" maxlength="20"><span class="des">*</span></td>
					</tr>
					<tr>
						<td><label>EFT规格</label> <input type="text" name="specName" readonly class="readonly" onblur="checkV(this,'',true)"/><a class=orga title="选择EFT规格" href="javascript:void(0)" onclick="selPos()">&nbsp;&nbsp;</a><span class="des">*</span></td>
						<!--  
						<td><label>软件版本号</label> <input name="firmwareVer" onblur="checkV(this,'',true)" maxlength="32"><span class="des">*</span></td>
						-->
						<td id="nospan"></td>
					</tr>
				</table>
			</div>
			<button type="button" onclick='onSave()'>保 存</button>   <button name="button" onclick='switchPage("listview")'>取 消</button>
		</form>
	</div>
	<div id="detview2" style="display:none;">
		<form id="batchPosForm" name="batchPosForm">
			<input type="hidden" name="id"/>
			<input type="hidden" name="spec"/>
			<div class=form>
			<div class="formTitle">批量添加EFT信息</div>
				<table cellSpacing=0 cellPadding=6 width="100%" border=0>
					<tr>
						<td><label>EFT起始编号</label> <input name="uniqueIdBegin" onblur="checkV(this,'pos',true)" maxlength="12"><span class="des">*</span></td>
						<td><label>EFT名称</label> <input name="name" onblur="checkV(this,'',true)" maxlength="20"><span class="des">*</span></td>
					</tr>
					<tr>
						<td><label>EFT结束编号</label> <input name="uniqueIdEnd" onblur="checkV(this,'pos',true)" maxlength="12" onKeyUp="checkEndPos()"><span class="des">*</span></td>
						<td><label>EFT规格</label> <input type="text" name="specName" readonly class="readonly" onblur="checkV(this,'',true)"/><a class=orga title="选择EFT规格" href="javascript:void(0)" onclick="selPos1()">&nbsp;&nbsp;</a><span class="des">*</span></td>
					</tr>
				</table>
			</div>
			<button type="button" onclick='onSaveBatch()'>保 存</button>   <button name="button" onclick='switchPage("listview")'>取 消</button>
		</form>
	</div>
	<div id="detview3" style="display:none;" align=center>
		<form id="posDetailForm" name="posDetailForm">
			<div class="form">
				<div class="formTitle">EFT明细</div>	
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable">
					<tr>
						<td><label>EFT编号</label> <span id="uniqueId" ></span></td>
			           	<td><label>EFT名称</label> <span id="name" ></span></td>
					</tr>	
					<tr>
					 	<td><label>所属机构</label> <span id="location" ></span></td>
					   	<td><label>EFT规格</label> <span id="specName" ></span></td>
					</tr>
					<tr>
					  	<td><label>状&nbsp;&nbsp;&nbsp;&nbsp;态</label> <span id="status" ></span></td>
					   	<td><label>生成日期</label> <span id="storeTime" ></span></td>
					</tr>
					<!--  
					<tr>
					   	<td><label>软件版本号</label> <span id="firmwareVer" ></span></td>
						<td></td>
					</tr>
					-->
				</table>
			</div>
			<button type="button" onclick="switchPage('listview')">返 回</button>
		</form>
	</div>
	</body>
</html>